﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DailyComics.Common.Utilities
{
  public class Cache<TKey, TValue>
  {
    protected Dictionary<TKey, TValue> dictionary;
    
    public int Count { get { return dictionary.Count; } }

    public Cache()
    {
      dictionary = new Dictionary<TKey, TValue>();
    }

    public bool ContainsKey(TKey key)
    {
      return dictionary.ContainsKey(key);
    }

    public virtual void Add(TKey key, TValue value)
    {
      if (!dictionary.ContainsKey(key))
      {
        dictionary.Add(key, value);
      }
    }

    public TValue this[TKey key]
    {
      get { return dictionary.ContainsKey(key) ? dictionary[key] : default(TValue); }
    }

    public void Clear()
    {
      dictionary.Clear();
    }

    private void Resize(int size)
    { }
  }
}
